def make_correlators(L, K, n, m, i, j, x, y):

  print "correlator"
  print "sites",
  for q in range(K):
    for p in range(L):
      print " %2i" %( ((q+j)%m)*n+(p+i)%n ),
  print ""
  if i != x or j != y:
    print "ti_sites",
    for q in range(K):
      for p in range(L):
        print " %2i" %( ((q+y)%m)*n+(p+x)%n ),
    print ""
  print "end"
  print ""

  if L != K:
    print "correlator"
    print "sites",
    for q in range(L):
      for p in range(K):
        print " %2i" %( ((q+j)%m)*n+(p+i)%n ),
    print ""
    if i != x or j != y:
      print "ti_sites",
      for q in range(L):
        for p in range(K):
          print " %2i" %( ((q+y)%m)*n+(p+x)%n ),
      print ""
    print "end"
    print ""

L = 2
K = 2
n = 4
m = 4

for j in range(m):
  for i in range(n):
    
    # a sublattice
    if (i+j) % 2 == 0:
      make_correlators(L, K, n, m, i, j, 0, 0)

    # b sublattice
    if (i+j) % 2 == 1:
      make_correlators(L, K, n, m, i, j, 1, 0)
